Passed
Push — feature/lighthouse ( 506e99...db2e00 )
by Kevin Van
11:37 queued 05:51
created

SponsorsBlock   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 1
1
import React, { Component } from "react"
2
import { graphql, StaticQuery, Link } from "gatsby"
3
4
import Sponsor from "./sponsor"
5
6
class SponsorsBlock extends Component {
7
  render() {
8
    const { sponsors } = this.props.data
9
    return (
10
      <>
11
        {sponsors.edges.map(({ node }, i) => {
12
          const website = (node.field_website && node.field_website.uri) || ""
13
          return (
14
            <Sponsor
15
              key={i}
16
              localFile={
17
                node.relationships.field_media_image.relationships
18
                  .field_media_image.localFile
19
              }
20
              uri={website}
21
            />
22
          )
23
        })}
24
        <Link to="/sponsors" className={"read-more"}>
25
          Alle sponsors &raquo;
26
        </Link>
27
      </>
28
    )
29
  }
30
}
31
32
const query = graphql`
33
  query {
34
    sponsors: allNodeSponsor(
35
      filter: {
36
        promote: { eq: true }
37
        status: { eq: true }
38
        field_type: { in: ["crossing", "green", "white"] }
39
      }
40
      sort: { fields: [field_type, title], order: ASC }
41
    ) {
42
      edges {
43
        node {
44
          title
45
          field_type
46
          field_website {
47
            uri
48
          }
49
          relationships {
50
            field_media_image {
51
              field_media_image {
52
                alt
53
              }
54
              relationships {
55
                field_media_image {
56
                  localFile {
57
                    ...KCVVFluid240
58
                  }
59
                }
60
              }
61
            }
62
          }
63
        }
64
      }
65
    }
66
  }
67
`
68
69
export default () => (
70
  <StaticQuery query={query} render={(data) => <SponsorsBlock data={data} />} />
71
)
72